package com.game.league.task.adapter;

import android.app.Activity;
import android.util.SparseIntArray;

import com.game.base.app.base.BaseAdapter;
import com.game.base.app.callback.ItemOnClick;
import com.game.base.glideV4.ImageLoader;
import com.game.league.R;
import com.game.league.databinding.TaskAdapterBinding;
import com.game.league.task.table.Task;

/**
 * 任务页
 * Created by Su on 2019/6/1.
 */
public class TaskAdapter extends BaseAdapter<Task, TaskAdapterBinding> {
    private SparseIntArray resIds = new SparseIntArray();

    public TaskAdapter(Activity activity, ItemOnClick itemOnClick) {
        super(activity, itemOnClick);
        initBg();
    }

    @Override
    protected int getLayoutResId(int viewType) {
        return R.layout.task_adapter;
    }

    @Override
    protected void onBindItem(TaskAdapterBinding binding, Task item, int position) {
        ImageLoader.loadRoundCenterCropInResource(mActivity, resIds.get(position % 6), binding.ivImage);
        binding.tvTitle.setText(item.getTitle());
    }

    private void initBg() {
        resIds.put(0, R.drawable.more_back1);
        resIds.put(1, R.drawable.more_back2);
        resIds.put(2, R.drawable.more_back3);
        resIds.put(3, R.drawable.more_back4);
        resIds.put(4, R.drawable.more_back5);
        resIds.put(5, R.drawable.more_back6);
    }
}
